<?php

/**
 * CreditMemo filter form base class.
 *
 * @package    erpcrm
 * @subpackage filter
 * @author     Your name here
 * @version    SVN: $Id: sfPropelFormFilterGeneratedTemplate.php 24171 2009-11-19 16:37:50Z Kris.Wallsmith $
 */
abstract class BaseCreditMemoFormFilter extends BaseFormFilterPropel
{
  public function setup()
  {
    $this->setWidgets(array(
      'customer_iden' => new sfWidgetFormPropelChoice(array('model' => 'AccountCustomer', 'add_empty' => true)),
      'credit_type'   => new sfWidgetFormPropelChoice(array('model' => 'ListDocumentTypes', 'add_empty' => true, 'key_method' => 'getTypeid')),
      'credit_number' => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'remarks'       => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'invoice_iden'  => new sfWidgetFormPropelChoice(array('model' => 'Invoice', 'add_empty' => true)),
      'amount'        => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'tax_code'      => new sfWidgetFormFilterInput(array('with_empty' => false)),
    ));

    $this->setValidators(array(
      'customer_iden' => new sfValidatorPropelChoice(array('required' => false, 'model' => 'AccountCustomer', 'column' => 'contact_iden')),
      'credit_type'   => new sfValidatorPropelChoice(array('required' => false, 'model' => 'ListDocumentTypes', 'column' => 'typeid')),
      'credit_number' => new sfValidatorPass(array('required' => false)),
      'remarks'       => new sfValidatorPass(array('required' => false)),
      'invoice_iden'  => new sfValidatorPropelChoice(array('required' => false, 'model' => 'Invoice', 'column' => 'invoice_iden')),
      'amount'        => new sfValidatorSchemaFilter('text', new sfValidatorNumber(array('required' => false))),
      'tax_code'      => new sfValidatorPass(array('required' => false)),
    ));

    $this->widgetSchema->setNameFormat('credit_memo_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    parent::setup();
  }

  public function getModelName()
  {
    return 'CreditMemo';
  }

  public function getFields()
  {
    return array(
      'credit_iden'   => 'ForeignKey',
      'customer_iden' => 'ForeignKey',
      'credit_type'   => 'ForeignKey',
      'credit_number' => 'Text',
      'remarks'       => 'Text',
      'invoice_iden'  => 'ForeignKey',
      'amount'        => 'Number',
      'tax_code'      => 'Text',
    );
  }
}
